/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package peticionweb.vista;

import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.InflaterInputStream;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManagerFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.jdom2.JDOMException;
import org.xml.sax.SAXException;
import peticionweb.control.PeticionPost;
import peticionweb.control.controladorPrincipal;
import peticionweb.control.exceptions.PreexistingEntityException;

/**
 *
 * @author icardenas
 */
public class PeticionWeb {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws MalformedURLException, UnsupportedEncodingException, IOException, ParserConfigurationException, SAXException {
        // TODO code application logic here
        controladorPrincipal peticion = new controladorPrincipal();
        try {
            InputStreamReader buffer = new InputStreamReader(System.in);
            BufferedReader lector = new BufferedReader(buffer);
            int opcion = 1;
            while (opcion != 0) {
                System.out.println("1 - CARGAR CARRERAS \n2 - CARGAR PERIODOS\n3 - CARGAR USUARIOS\n0 - SALIR  ");
                String lectura = lector.readLine();
                
                opcion = Integer.parseInt(lectura.isEmpty()?"0":lectura);
                switch (opcion) {
                    case 1:
                        peticion.cargarEspecialidad("http://admision.unet.edu.ve/pages/main.php?id=116");
                        break;
                    case 2:
                        peticion.cargarPeriodos("http://admision.unet.edu.ve/pages/main.php?id=116");
                        break;
                    case 3:
                        peticion.cargarResultados("http://admision.unet.edu.ve/pages/listado.php");
                        break;
                    case 4:
                        break;
                    case 5:
                        break;
                    case 6:
                        break;
                    default:
                        break;
                }
                System.out.println("");
            }

        } catch (PreexistingEntityException ex) {
            Logger.getLogger(PeticionWeb.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(PeticionWeb.class.getName()).log(Level.SEVERE, null, ex);
        }

    }


}
